using System.Collections.Generic;
using System.Data.Common;
using System;
namespace Smallpointer.Data
{
    internal enum DataTypeMode
    {
        Binary = 0,
        VarBinary,
        Bit,
        DateTime,
        Date,
        Decimal,
        Float,
        Int,
        Money,
        NChar,
        VarChar,
        NText,
        Text,
        NVarChar,
        Real,
        UniqueIdentifier,
        None,
    }
    internal enum ConnType
    {
        None,
        MsSql,
        MySql,
        Oracle,
        Access,
        Sqlite,
    }
    internal enum DataSpace
    {
        Resource,
        File
    }
    [Serializable]
    internal struct DataProperty
    {
        public string key { get; set; }
        public string datatype { get; set; }
        public string length { get; set; }
        public string defualt { get; set; }
        public bool isprimary { get; set; }
        public bool isnull { get; set; }
        public bool identity { get; set; }
        public bool isreadonly { get; set; }

        public static bool operator !=(DataProperty data1, DataProperty data2)
        {
            return !data1.Equals(data2);
        }

        public static bool operator ==(DataProperty data1, DataProperty data2)
        {
            return !data1.Equals(data2);
        }

        public bool Equals(DataProperty obj)
        {
            return Equals(obj.key, key) && Equals(obj.datatype, datatype) && Equals(obj.length, length) && Equals(obj.defualt, defualt) && obj.isprimary.Equals(isprimary) && obj.isnull.Equals(isnull) && obj.identity.Equals(identity) && obj.isreadonly.Equals(isreadonly);
        }

        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(DataProperty)) return false;
            return Equals((DataProperty)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = (key != null ? key.GetHashCode() : 0);
                result = (result * 397) ^ (datatype != null ? datatype.GetHashCode() : 0);
                result = (result * 397) ^ (length != null ? length.GetHashCode() : 0);
                result = (result * 397) ^ (defualt != null ? defualt.GetHashCode() : 0);
                result = (result * 397) ^ isprimary.GetHashCode();
                result = (result * 397) ^ isnull.GetHashCode();
                result = (result * 397) ^ identity.GetHashCode();
                result = (result * 397) ^ isreadonly.GetHashCode();
                return result;
            }
        }
    }
    internal struct DataRelational
    {
        public string key { get; set; }
        public string name { get; set; }

        public static bool operator !=(DataRelational data1, DataRelational data2)
        {
            return !data1.Equals(data2);
        }

        public static bool operator ==(DataRelational data1, DataRelational data2)
        {
            return !data1.Equals(data2);
        }

        public bool Equals(DataRelational obj)
        {
            return Equals(obj.key, key) && Equals(obj.name, name);
        }

        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(DataRelational)) return false;
            return Equals((DataRelational)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return ((key != null ? key.GetHashCode() : 0) * 397) ^ (name != null ? name.GetHashCode() : 0);
            }
        }
    }
    internal struct DataMapItem
    {
        public string Name { get; set; }
        public List<DataProperty> Properties { get; set; }
        public List<DataRelational> Parent { get; set; }
        public List<DataRelational> Child { get; set; }
    }
    internal struct DataParameterItem
    {
        public string Name { get; set; }
        public string Sql { get; set; }
        public Dictionary<string, DbParameter> Parameters { get; set; }
    }
    internal class DataMap : Dictionary<string, object>
    {
        public string Name { get; set; }
    }
    internal class DataRelationMap : Dictionary<string, List<DataConfigMap>>
    {

    }
    internal class DataConfigMap : Dictionary<string, DataProperty>
    {
        public string Name { get; set; }
    }
}